SONARJAVA-6686 Implement new rule S2198: Unnecessary mathematical comparisons - #5845
SONARJAVA-6686 Implement new rule S2198: Unnecessary mathematical comparisons#5845romainbrenguier wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
It looks like it's was not addded to the profiles
|
❌ Ruling needs updating. A fix PR has been created: #5846 Please review and merge it into your branch. |
|
❌ Ruling needs updating. A fix PR has been created: #5846 Please review and merge it into your branch. |
Ruling Diff SummaryDetected changes in 3 rule files: 0 issues removed, 12 issues added. S2198 (
|
|
❌ Ruling needs updating. A fix PR has been created: #5846 Please review and merge it into your branch. |
|
❌ Ruling needs updating. A fix PR has been created: #5856 Please review and merge it into your branch. |
1212538 to
691c064
Compare
Detect comparisons between a bounded numeric primitive (byte, short, char, int) and a compile-time constant outside the type's value range, which always evaluate to true or false.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Move trailing comment to previous empty line (convention) - Add missing curly braces on if/else statements - Reduce cognitive complexity by extracting helper methods Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
691c064 to
a1ce778
Compare
|
❌ Ruling needs updating. A fix PR has been created: #5856 Please review and merge it into your branch. |
1 similar comment
|
❌ Ruling needs updating. A fix PR has been created: #5856 Please review and merge it into your branch. |
CI failed: Integration test failures in JavaRulingTest caused by missing or outdated ruling expectations for the newly introduced rule S2198.OverviewAll analyzed CI failures stem from test assertions in FailuresRuling Integration Test Mismatches (confidence: high)
Summary
Code Review ✅ Approved 2 resolved / 2 findingsImplements new rule S2198 to detect unnecessary mathematical comparisons with out-of-range constants, addressing the rule activation and message stability findings. ✅ 2 resolved✅ Quality: New rule S2198 may not be activated in Sonar way profile
✅ Quality: Draft PR: sample uses Noncompliant without message stability check
Tip Comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|




Detect comparisons between a bounded numeric primitive (byte, short, char, int) and a compile-time constant outside the type's value range, which always evaluate to true or false.
Part of